<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="../../css/weui.min.css" />
    <link rel="stylesheet" type="text/css" href="../../css/jquery-weui.min.css" />
    <link rel="stylesheet" type="text/css" href="../../css/index.css" />
    <link rel="stylesheet" type="text/css" href="../../css/order.css" />
    <title>开票信息</title>
    <script src="../../js/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery-weui.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/baseConfig.js" type="text/javascript" charset="utf-8"></script>
    <script src=" http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
</head>
<style type="text/css">
    .weui-uploader__file {
        width: 12rem;
        height: 7.5rem;
        margin: 1rem 2.2rem;
        background: no-repeat;
        position: relative;
    }
    
    .weui-uploader__file .delete {
        position: absolute;
        right: 0;
        top: 0;
        width: 1.45rem;
        height: 1.45rem;
    }
</style>

<body>
    <!--<div id="header">
			<div class="header-title" style="position: fixed;top: 0;">
				<img src="../../img/left.png" class="left" />
				<span>开票信息</span>
			</div>
		</div>-->
    <div class="ticketInfo_warp" style="color: #444;margin-top: 0;">
        <p>
            <span>户名</span>
            <em class="name"></em>
        </p>
        <p>
            <span>税号</span>
            <b class="dutyNo"></b>
        </p>
        <p>
            <span>地址</span>
            <b class="address"></b>
        </p>
        <p>
            <span>电话</span>
            <em class="tel"></em>
        </p>
        <p>
            <span>开户行</span>
            <b class="bank"></b>
        </p>
        <p>
            <span>账号</span>
            <em class="account"></em>
        </p>
        <p>
            <span>行号</span>
            <em class="bankNo"></em>
        </p>
        <div class="uploadTicket" style="display: none;">
            <div class="weui-cells weui-cells_form">
                <form method="post" id="form1">
                    <div class="weui-cell" style="padding: 0;">
                        <div class="weui-cell__bd">
                            <div class="weui-uploader__bd">
                                <ul class="weui-uploader__files">

                                </ul>
                                <div class="weui-uploader__input-box" style="width: 12rem;height: 7.5rem;margin: 1rem 2.2rem;">
                                    <input id="uploaderInput" class="weui-uploader__input js_file" type="file" accept="image/*">
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="demos-content-padded">
                <a href="javascript:;" class="weui-btn weui-btn_primary">上传发票快递单</a>
            </div>
        </div>
        <div class="ticketImg" style="display: none;">
            <img src="../../img/photo.png" />
        </div>
    </div>
    <div class="weui-gallery" style="display: none">
        <span class="weui-gallery__img"></span>
    </div>
</body>
<script type="text/javascript">
    $(document).ready(function() {
    	var kaiPiao = baseConfig.GetQueryString("kaipiaoId")
        $.showLoading("加载中...");
        baseConfig.historyBack();
        $.ajax({
            type: "get",
            url: baseConfig.localHttp + "weChatApi/fgclient/getKaiPiaoInfo",
            async: false,
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            },
            data: {
                kaipiaoId: kaiPiao, //baseConfig.GetQueryString("kaipiaoId")  先用假数据，这个字段后台还没加
            },
            success: function(data) {
                $.hideLoading();
                //					console.log(data)
                var content = data.content
                if (data.code == 100) {
                    $(".name").html(content.name);
                    $(".dutyNo").html(content.dutyNo);
                    $(".address").html(content.address);
                    $(".tel").html(content.tel);
                    $(".bank").html(content.bank);
                    $(".account").html(content.account);
                    $(".bankNo").html(content.bankNo);
                    if (!content.image) {
                        $(".uploadTicket").show()
                        baseConfig.singleImgupload()
                        $(".weui-btn").on("click", function() {
                            var formData = new FormData($("#form1")[0])
                            formData.append("kaipiaoId", baseConfig.GetQueryString("kaipiaoId")); //开票id应该是要获取的
                            $.ajax({
                                type: "get",
                                url: baseConfig.localHttp + "weChatApi/fgclient/uploadKaiPiaoPic",
                                async: false,
                                headers: {
                                    'Content-Type': 'application/x-www-form-urlencoded'
                                },
                                data: formData,
                                success: function(data) {
                                    console.log(data)
                                    if (data.code == 100) {
                                        $.toptip(data.content, 1200, 'success')
                                        setTimeout(function() {
                                            history.back()
                                        }, 1200)
                                    } else {
                                        $.toptip(data.content, 1200, 'error');
                                    }
                                },
                                error: function() {

                                }
                            })
                        })

                    } else {
                        $(".ticketImg").show()
                        $(".ticketImg").find("img").attr("src", baseConfig.imglocalHttp + content.image)
                        $(".ticketImg img").on("click", function() {
                            // var src = $(this).attr("src")
                            // $(".weui-gallery").show()
                            // $(".weui-gallery__img").css("background-image", "url("+src+")")
                            // $(".weui-gallery").on("click", function() {
                            // 	$(this).hide()
                            // })
                            var imgsurl = [];
                            imgsurl[0] = this.src;
                            var nowurl = this.src;
                            wx.previewImage({
                                current: nowurl,
                                urls: imgsurl
                            });
                        })
                    }
                } else {
                    $.toptip(data.content, 1200, 'error');
                }
            },
            error: function(data) {
                $.hideLoading();
            }
        })
    })
</script>

</html>